import matplotlib.pyplot as plt

class population: 
    def __init__(self, startpop, geburtrate, sterberate):
        self.startpop=startpop
        self.geburtrate=geburtrate 
        self.sterberate=sterberate
        self.list=[]  #Liste erstellen


    def setup (self, startzeit, endzeit, schritt):
        self.startzeit=startzeit
        self.endzeit=endzeit
        self.schritt=schritt

    def run (self):
        run1=1
        x=0
        self.run=((self.endzeit-self.startzeit)/self.schritt)
        while x < self.run:
            if run1==1:
                population=self.startpop
                run1=0

            else :
                geburten=population*(self.geburtrate*self.schritt)
                gestorbene=(population*(self.sterberate*self.schritt))
                population=population+geburten-gestorbene

            self.list.append(population) # speichern in Liste
            x=x+1
                        
        

    def getpop (self, anfrage): 
        pop=self.list[int(anfrage/self.schritt)]
        print "Population im Jahr", anfrage, "war", pop

    def draw(self):
        for y in range (int(len(self.list)*self.schritt)):
            plt.plot([y],[self.list[int(y/self.schritt)]], ':rs')
        plt.ylabel("Population")
        plt.xlabel("Jahr")
        plt.show()
            
        
pop=population(20,0.2,0.1)
pop.setup (0,100,0.1)
pop.run ()
pop.draw()

pop2=population (20,0.2,0.1)
pop2.setup(0,100,1)
pop2.run ()





